load("@fbsource//tools/build_defs:rust_library.bzl", "rust_library")

oncall("sapling")

rust_library(
    name = "util",
    srcs = glob(["src/**/*.rs"]),
    autocargo = {"cargo_toml_config": {
        "dependencies_override": {"target": {'\'cfg(target_os = "windows")\'': {"dependencies": {"winapi": {"features": [
            "fileapi",
            "winnt",
            "handleapi",
            "winbase",
            "winerror",
        ]}}}}},
        "lib": {"name": "util"},
        "package": {
            "authors": ["Meta Source Control Team <sourcecontrol-dev@meta.com>"],
            "description": "Misc utilities used by Sapling.",
            "homepage": "https://sapling-scm.com/",
            "license": "MIT",
            "name": "sapling-util",
            "repository": "https://github.com/facebook/sapling",
        },
    }},
    crate_root = "src/lib.rs",
    os_deps = [
        (
            "linux",
            [
                "fbsource//third-party/rust:libc",
                "fbsource//third-party/rust:tempfile",
            ],
        ),
        (
            "macos",
            [
                "fbsource//third-party/rust:libc",
                "fbsource//third-party/rust:tempfile",
            ],
        ),
        (
            "windows",
            [
                "fbsource//third-party/rust:widestring",
                "fbsource//third-party/rust:winapi",
            ],
        ),
    ],
    test_deps = [
        "fbsource//third-party/rust:memmap2",
        "fbsource//third-party/rust:tempfile",
    ],
    test_os_deps = [
        (
            "windows",
            [
                "fbsource//third-party/rust:tempfile",
            ],
        ),
    ],
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:dirs",
        "fbsource//third-party/rust:fn-error-context",
        "fbsource//third-party/rust:fs-err",
        "fbsource//third-party/rust:fs2",
        "fbsource//third-party/rust:once_cell",
        "fbsource//third-party/rust:rand",
        "fbsource//third-party/rust:shellexpand",
        "fbsource//third-party/rust:thiserror",
        "fbsource//third-party/rust:tracing",
        "//eden/scm/lib/atomicfile:atomicfile",
        "//eden/scm/lib/lazystr:lazystr",
        "//eden/scm/lib/metrics:metrics",
        "//eden/scm/lib/util/rewrite-macros:rewrite-macros",
    ],
)
